package com.cat.dataStructure;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/
 * @create 2025/8/19 09:42
 * @since JDK17
 */

public class Solution32 {


    public boolean[] canEat(int[] candiesCount, int[][] queries) {
        int n = candiesCount.length, m = queries.length;
        boolean[] ans = new boolean[m];
        int[] prefix = new int[n + 1];
        for (int i = 0; i < n; i++) {   // 前缀和
            prefix[i + 1] = prefix[i] + candiesCount[i];
        }
        // q[i][0] 类型
        // q[i][1] 天数
        // q[i][2] 限制
        for (int i = 0, a, b, c; i < m; i++) {   //
            a = queries[i][0];  // 类型
            b = queries[i][1] + 1;  // 天数
            c = queries[i][2];  // 限制
            if ((long)b * c > prefix[a] && b <= prefix[a + 1]) {
                ans[i] = true;
            } else {
                ans[i] = false;
            }
        }

        return ans;
    }
}
